package com.ht.impl.demo;

import com.ht.aems.util.RtDataBuffer;

import com.ht.memcached.MemCachedConfigurator;
import com.ht.impl.CustomGraphCompent;
import com.mxgraph.util.mxConstants;
import com.htgraph.renderer.CellRenderer4FJ;
import com.htgraph.flash.DefaultFlasher;
import com.htgraph.util.GraphComponentUtil;
import org.apache.log4j.BasicConfigurator;

import javax.swing.*;
import java.io.IOException;

import rtdb.RtDataHandler_MemCached;

/**
 * Created by IntelliJ IDEA.
 *
 * @author Wang jiaxiang
 *         Date: 2010-9-2
 */
public class GraphViewerDemo4FJ {
    public static void main(String[] args) throws IOException, InterruptedException {
        BasicConfigurator.configure();
        MemCachedConfigurator.config(new String[]{"192.168.1.107:11211"}, new Integer[]{1});
        CustomGraphCompent compent = new CustomGraphCompent(false);
        compent.setToolTips(false);
        compent.getGraph().setCellsSelectable(false);
        compent.setMxeSource(CustomGraphCompent.class.getResourceAsStream("/mxefile/xxx.mxe"));

        CellRenderer4FJ dataUpdator = new CellRenderer4FJ(compent.getGraph().getModel());

        final RtDataBuffer buffer = new RtDataBuffer();
        buffer.setKeys(dataUpdator.buildKeys().toArray(new String[]{}));//todo: set keys here
        buffer.setHandler(new RtDataHandler_MemCached());
        DefaultFlasher flasher = new DefaultFlasher(compent.getGraph().getModel(), mxConstants.STYLE_STROKECOLOR);

        JFrame frame = new JFrame();
        frame.add(compent);
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        GraphComponentUtil.startUpdateThread(compent, frame, buffer, dataUpdator, flasher);
        frame.pack();
        frame.setVisible(true);

    }
}
